import rpy
from rpy import r

import catcher

def summary(obj):
    """ show a summary of an R object with name obj """
    c=catcher.Catcher()
    rpy.set_rpy_output(catcher.catcher)
    rpy.set_default_mode(rpy.NO_CONVERSION)
    summary=rpy.r("summary("+obj+")")
    rpy.set_default_mode(rpy.BASIC_CONVERSION)
    rpy.r.print_(summary)
    s = c.getText()
    c.reset()
    return s

def print_(obj):
    c=catcher.Catcher()
    rpy.set_rpy_output(catcher.catcher)
    rpy.set_default_mode(rpy.NO_CONVERSION)
    object=rpy.r.get(obj)
    rpy.set_default_mode(rpy.BASIC_CONVERSION)
    rpy.r.print_(object)
    s = c.getText()
    c.reset()
    return s
    
